#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

int calLen(int num){
	if(num==0) return 1;
	int len=0;
	while(num!=0){
		len++;
		num/=10;
	}
	return len;
}

int toInt(char s[]){
	int len=strlen(s);
	int x=0;
	for(int i=0;i<len;i++){
		x=x*10+s[i]-'0';
	}
	return x;
}

int main(){
//	freopen("test.out","w",stdout);
	int flag=0;
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		char c;
		char s1[20]={0},s2[20];
		int num1=0,num2=0;
		fflush(stdin);
		cin>>c>>s1>>s2;
		//scanf("%c %i %d",&c,&num1,&num2);
		num1=toInt(s1);
		num2=toInt(s2);
	//	cout<<c<<" "<<num1<<" "<<num2<<endl;
		//注意数字第二位为0的情况 1072 
		 
		
		
		
		switch(c){
			case 'a':flag=1;
				break;
			case 'b':flag=2;
				break;
			case 'c':flag=3;
				break;
			default:
				num1=(c-'0')*pow(10,strlen(s1))+toInt(s1);
				
		}
		int l1=calLen(num1);
		int l2=calLen(num2);
		int k=l1+l2+2;
		switch(flag){
			case 1:
				cout<<num1<<"+"<<num2<<"="<<num1+num2<<endl;
				cout<<k+calLen(num1+num2)<<endl;
				break;
			case 2:
				cout<<num1<<"-"<<num2<<"="<<num1-num2<<endl;
				k=k+calLen(num1-num2);
				if(num1<num2) 
					k++;
				cout<<k<<endl;
				break;
			case 3:
				cout<<num1<<"*"<<num2<<"="<<num1*num2<<endl;
				cout<<k+calLen(num1*num2)<<endl;
				break;
		}
	}

	return 0;
}
